package org.jason.interaction.mq.producer;

import cn.dev33.satoken.stp.StpUtil;
import org.jason.common.constants.ArticleInteractionConstants;
import org.jason.model.common.dtos.ResponseResult;
import org.jason.model.common.enums.HttpCodeEnum;
import org.jason.model.interaction.dtos.ArticleInteractionDto;
import org.jason.model.interaction.dtos.SendCommentDto;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class CommentProducer {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    //创建发布评论队列
    public ResponseResult createComment(SendCommentDto dto) {
        int userId = StpUtil.getLoginIdAsInt();
        dto.setUserId(userId);
        rabbitTemplate.convertAndSend("comment.queue", dto);
        return ResponseResult.get(HttpCodeEnum.SUCCESS);
    }
}
